package com.union.vehicleassistant.util.refresh;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.animation.AlphaInAnimation;
import com.chad.library.adapter.base.animation.ScaleInAnimation;
import com.chad.library.adapter.base.animation.SlideInBottomAnimation;
import com.chad.library.adapter.base.animation.SlideInLeftAnimation;
import com.chad.library.adapter.base.animation.SlideInRightAnimation;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;


/**
 * @author CuiZhen
 * @date 2019/5/20
 * GitHub: https://github.com/goweii
 */
public class RvConfigUtils {

    public static class RvAnim {
        public static final int NONE = 0;
        public static final int ALPHA_IN = 1;
        public static final int SCALE_IN = 2;
        public static final int SLIDE_IN_BOTTOM = 3;
        public static final int SLIDE_IN_LEFT = 4;
        public static final int SLIDE_IN_RIGHT = 5;
    }

    public static String getName(int anim) {
        String name = "";
        switch (anim) {
            default:
                break;
            case RvAnim.NONE:
                name = "无";
                break;
            case RvAnim.ALPHA_IN:
                name = "渐显";
                break;
            case RvAnim.SCALE_IN:
                name = "缩放";
                break;
            case RvAnim.SLIDE_IN_BOTTOM:
                name = "底部滑入";
                break;
            case RvAnim.SLIDE_IN_LEFT:
                name = "左侧滑入";
                break;
            case RvAnim.SLIDE_IN_RIGHT:
                name = "右侧滑入";
                break;
        }
        return name;
    }

    public static void init(BaseQuickAdapter<?, ? extends BaseViewHolder> adapter) {
        adapter.getLoadMoreModule().setLoadMoreView(new BRVHLoadMoreView());
    }

    public static void setAnim(BaseQuickAdapter<?, ? extends BaseViewHolder> adapter, int anim) {
        adapter.setAnimationEnable(true);
        switch (anim) {
            default:
                break;
            case RvAnim.NONE:
                adapter.setAnimationEnable(false);
                break;
            case RvAnim.ALPHA_IN:
                adapter.setAdapterAnimation(new AlphaInAnimation());
                break;
            case RvAnim.SCALE_IN:
                adapter.setAdapterAnimation(new ScaleInAnimation());
                break;
            case RvAnim.SLIDE_IN_BOTTOM:
                adapter.setAdapterAnimation(new SlideInBottomAnimation());
                break;
            case RvAnim.SLIDE_IN_LEFT:
                adapter.setAdapterAnimation(new SlideInLeftAnimation());
                break;
            case RvAnim.SLIDE_IN_RIGHT:
                adapter.setAdapterAnimation(new SlideInRightAnimation());
                break;
        }
    }
}
